package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:Thread类的常见属性方法
 * User: bjc
 * Date: 2025-08-14
 * Time: 20:53
 */
public class ThreadDemo7 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while (true) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "t1");
        System.out.println(t.getName());
        System.out.println(t.getState());
        System.out.println(t.getPriority());





        //判断线程是否是守护线程
        System.out.println(t.isDaemon());
        t.setDaemon(true);//设置为守护线程,即随主线程结束而结束
        //开启线程
        t.start();
    }
}
